package webjoch.methods;

import java.util.ArrayList;

import com.rsbuddy.script.util.Filter;

import webjoch.Main;
import webjoch.wrappers.Link;
import webjoch.wrappers.Room;

/**
 * 
 * @author Webjoch
 *
 */
public class Links {
	/**
	 * Gets the Links from a room
	 * @param room Room to get the links from
	 * @return all links from the room
	 */
	public static Link[] getRoomLinks(Room room){
		ArrayList<Link> links = new ArrayList<Link>();
		for (Link link : Main.getDungeon().getMap()){
			if (link.getRoom().getLocation().equals(room.getLocation())){
				links.add(link);
			}
		}
		return links.toArray(new Link[links.size()]);
	}
	
	public static Link[] getRoomLinks(Room room, Filter<Link> filter){
		ArrayList<Link> links = new ArrayList<Link>();
		for (Link link : getRoomLinks(room)){
			if (!filter.accept(link)) continue;
			links.add(link);
		}
		return links.toArray(new Link[links.size()]);
	}
}
